using System;
using System.Management.Automation.Host;

namespace Wolfpack.Contrib.Checks.Powershell
{
    /// <summary>
    /// Defines the low-level host functionality, such as read and write actions,
    /// that a host application can implement to support cmdlets that perform 
    /// character-mode interaction with the user. 
    /// </summary>
    public /*internal*/ class WolfpackPSHostRawUserInterface : PSHostRawUserInterface
    {
        /// <summary>
        /// Reads a pressed and released keystroke from the keyboard device, 
        /// blocking processing until a keystroke is typed.
        /// </summary>
        /// <exception cref="NotImplementedException">
        /// Scripts hosted by Wolfpack must not call this method.
        /// </exception>
        public override KeyInfo ReadKey(ReadKeyOptions options)
        {
            throw WolfpackPSHost.InvalidOperation();
        }

        /// <summary>
        /// Flushes the input buffer. All input currently in the buffer is discarded. 
        /// </summary>
        public override void FlushInputBuffer()
        {
        }

        /// <summary>
        /// Copies a given character to a region of the screen buffer.
        /// </summary>
        /// <exception cref="NotImplementedException">
        /// Scripts hosted by Wolfpack must not call this method.
        /// </exception>
        public override void SetBufferContents(Coordinates origin, BufferCell[,] contents)
        {
            throw WolfpackPSHost.InvalidOperation();
        }

        /// <summary>
        /// Copies a given character to a region of the screen buffer.
        /// </summary>
        /// <exception cref="NotImplementedException">
        /// Scripts hosted by Wolfpack must not call this method.
        /// </exception>
        public override void SetBufferContents(Rectangle rectangle, BufferCell fill)
        {
            throw WolfpackPSHost.InvalidOperation();
        }

        /// <exception cref="NotImplementedException">
        /// Scripts hosted by Wolfpack must not call this method.
        /// </exception>
        public override BufferCell[,] GetBufferContents(Rectangle rectangle)
        {
            throw WolfpackPSHost.InvalidOperation();
        }

        /// <exception cref="NotImplementedException">
        /// Scripts hosted by Wolfpack must not call this method.
        /// </exception>
        public override void ScrollBufferContents(Rectangle source, Coordinates destination, Rectangle clip, BufferCell fill)
        {
            throw WolfpackPSHost.InvalidOperation();
        }

        public override ConsoleColor ForegroundColor
        {
            get { return ConsoleColor.White; }
            set { }
        }

        public override ConsoleColor BackgroundColor
        {
            get { return ConsoleColor.Black; }
            set { }
        }

        /// <exception cref="NotImplementedException">
        /// Scripts hosted by Wolfpack must not call this method.
        /// </exception>
        public override Coordinates CursorPosition
        {
            get { throw WolfpackPSHost.InvalidOperation(); }
            set { throw WolfpackPSHost.InvalidOperation(); }
        }

        public override Coordinates WindowPosition
        {
            get { return new Coordinates(0, 0); }
            set { }
        }

        public override int CursorSize
        {
            get { return 1; }
            set { }
        }

        public override Size BufferSize
        {
            get { return new Size(80, 100); }
            set { }
        }

        public override Size WindowSize
        {
            get { return new Size(80, 100); }
            set { }
        }

        public override Size MaxWindowSize
        {
            get { return new Size(80, 100); }
        }

        public override Size MaxPhysicalWindowSize
        {
            get { return new Size(80, 100); }
        }

        public override bool KeyAvailable
        {
            get { return false; }
        }

        public override string WindowTitle
        {
            get { return string.Empty; }
            set { }
        }
    }
}